1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module rsvg.Handle;
26 
27 private import cairo.Context;
28 private import gdkpixbuf.Pixbuf;
29 private import gio.Cancellable;
30 private import gio.FileIF;
31 private import gio.InputStream;
32 private import glib.ConstructionException;
33 private import glib.ErrorG;
34 private import glib.GException;
35 private import glib.Str;
36 private import glib.c.functions;
37 private import gobject.ObjectG;
38 private import rsvg.c.functions;
39 public  import rsvg.c.types;
40 
41 
42 /**
43  * [class@Rsvg.Handle] loads an SVG document into memory.
44  * 
45  * This is the main entry point into the librsvg library.  An [class@Rsvg.Handle] is an
46  * object that represents SVG data in memory.  Your program creates an
47  * [class@Rsvg.Handle] from an SVG file, or from a memory buffer that contains SVG data,
48  * or in the most general form, from a `GInputStream` that will provide SVG data.
49  * 
50  * Librsvg can load SVG images and render them to Cairo surfaces,
51  * using a mixture of SVG's [static mode] and [secure static mode].
52  * Librsvg does not do animation nor scripting, and can load
53  * references to external data only in some situations; see below.
54  * 
55  * Librsvg supports reading [SVG 1.1](https://www.w3.org/TR/SVG11/) data, and is gradually
56  * adding support for features in [SVG 2](https://www.w3.org/TR/SVG2/).  Librsvg also
57  * supports SVGZ files, which are just an SVG stream compressed with the GZIP algorithm.
58  * 
59  * [static mode]: https://www.w3.org/TR/SVG2/conform.html#static-mode
60  * [secure static mode]: https://www.w3.org/TR/SVG2/conform.html#secure-static-mode
61  * 
62  * # The "base file" and resolving references to external files
63  * 
64  * When you load an SVG, librsvg needs to know the location of the "base file"
65  * for it.  This is so that librsvg can determine the location of referenced
66  * entities.  For example, say you have an SVG in `/foo/bar/foo.svg`
67  * and that it has an image element like this:
68  * 
69  * ```
70  * <image href="resources/foo.png" .../>
71  * ```
72  * 
73  * In this case, librsvg needs to know the location of the toplevel
74  * `/foo/bar/foo.svg` so that it can generate the appropriate
75  * reference to `/foo/bar/resources/foo.png`.
76  * 
77  * ## Security and locations of referenced files
78  * 
79  * When processing an SVG, librsvg will only load referenced files if they are
80  * in the same directory as the base file, or in a subdirectory of it.  That is,
81  * if the base file is `/foo/bar/baz.svg`, then librsvg will
82  * only try to load referenced files (from SVG's
83  * `<image>` element, for example, or from content
84  * included through XML entities) if those files are in `/foo/bar/<anything>` or in `/foo/bar/<anything>\/.../<anything>`.
85  * This is so that malicious SVG files cannot include files that are in a directory above.
86  * 
87  * The full set of rules for deciding which URLs may be loaded is as follows;
88  * they are applied in order.  A referenced URL will not be loaded as soon as
89  * one of these rules fails:
90  * 
91  * 1. All `data:` URLs may be loaded.  These are sometimes used
92  * to include raster image data, encoded as base-64, directly in an SVG file.
93  * 
94  * 2. All other URL schemes in references require a base URL.  For
95  * example, this means that if you load an SVG with
96  * [ctor@Rsvg.Handle.new_from_data] without calling [method@Rsvg.Handle.set_base_uri],
97  * then any referenced files will not be allowed (e.g. raster images to be
98  * loaded from other files will not work).
99  * 
100  * 3. If referenced URLs are absolute, rather than relative, then they must
101  * have the same scheme as the base URL.  For example, if the base URL has a
102  * `file` scheme, then all URL references inside the SVG must
103  * also have the `file` scheme, or be relative references which
104  * will be resolved against the base URL.
105  * 
106  * 4. If referenced URLs have a `resource` scheme, that is,
107  * if they are included into your binary program with GLib's resource
108  * mechanism, they are allowed to be loaded (provided that the base URL is
109  * also a `resource`, per the previous rule).
110  * 
111  * 5. Otherwise, non-`file` schemes are not allowed.  For
112  * example, librsvg will not load `http` resources, to keep
113  * malicious SVG data from "phoning home".
114  * 
115  * 6. A relative URL must resolve to the same directory as the base URL, or to
116  * one of its subdirectories.  Librsvg will canonicalize filenames, by
117  * removing ".." path components and resolving symbolic links, to decide whether
118  * files meet these conditions.
119  * 
120  * # Loading an SVG with GIO
121  * 
122  * This is the easiest and most resource-efficient way of loading SVG data into
123  * an [class@Rsvg.Handle].
124  * 
125  * If you have a `GFile` that stands for an SVG file, you can simply call
126  * [ctor@Rsvg.Handle.new_from_gfile_sync] to load an [class@Rsvg.Handle] from it.
127  * 
128  * Alternatively, if you have a `GInputStream`, you can use
129  * [ctor@Rsvg.Handle.new_from_stream_sync].
130  * 
131  * Both of those methods allow specifying a `GCancellable`, so the loading
132  * process can be cancelled from another thread.
133  * 
134  * ## Loading an SVG from memory
135  * 
136  * If you already have SVG data in a byte buffer in memory, you can create a
137  * memory input stream with [ctor@Gio.MemoryInputStream.new_from_data] and feed that
138  * to [ctor@Rsvg.Handle.new_from_stream_sync].
139  * 
140  * Note that in this case, it is important that you specify the base_file for
141  * the in-memory SVG data.  Librsvg uses the base_file to resolve links to
142  * external content, like raster images.
143  * 
144  * # Loading an SVG without GIO
145  * 
146  * You can load an [class@Rsvg.Handle] from a simple filename or URI with
147  * [ctor@Rsvg.Handle.new_from_file].  Note that this is a blocking operation; there
148  * is no way to cancel it if loading a remote URI takes a long time.  Also, note that
149  * this method does not let you specify [flags@Rsvg.HandleFlags].
150  * 
151  * Otherwise, loading an SVG without GIO is not recommended, since librsvg will
152  * need to buffer your entire data internally before actually being able to
153  * parse it.  The deprecated way of doing this is by creating a handle with
154  * [ctor@Rsvg.Handle.new] or [ctor@Rsvg.Handle.new_with_flags], and then using
155  * [method@Rsvg.Handle.write] and [method@Rsvg.Handle.close] to feed the handle with SVG data.
156  * Still, please try to use the GIO stream functions instead.
157  * 
158  * # Resolution of the rendered image (dots per inch, or DPI)
159  * 
160  * SVG images can contain dimensions like "`5cm`" or
161  * "`2pt`" that must be converted from physical units into
162  * device units.  To do this, librsvg needs to know the actual dots per inch
163  * (DPI) of your target device.  You can call [method@Rsvg.Handle.set_dpi] or
164  * [method@Rsvg.Handle.set_dpi_x_y] on an [class@Rsvg.Handle] to set the DPI before rendering
165  * it.
166  * 
167  * # Rendering
168  * 
169  * The preferred way to render a whole SVG document is to use
170  * [method@Rsvg.Handle.render_document].  Please see its documentation for
171  * details.
172  * 
173  * # API ordering
174  * 
175  * Due to the way the librsvg API evolved over time, an [class@Rsvg.Handle] object is available
176  * for use as soon as it is constructed.  However, not all of its methods can be
177  * called at any time.  For example, an [class@Rsvg.Handle] just constructed with [ctor@Rsvg.Handle.new]
178  * is not loaded yet, and it does not make sense to call [method@Rsvg.Handle.render_document] on it
179  * just at that point.
180  * 
181  * The documentation for the available methods in [class@Rsvg.Handle] may mention that a particular
182  * method is only callable on a "fully loaded handle".  This means either:
183  * 
184  * * The handle was loaded with [method@Rsvg.Handle.write] and [method@Rsvg.Handle.close], and
185  * those functions returned no errors.
186  * 
187  * * The handle was loaded with [method@Rsvg.Handle.read_stream_sync] and that function
188  * returned no errors.
189  * 
190  * Before librsvg 2.46, the library did not fully verify that a handle was in a
191  * fully loaded state for the methods that require it.  To preserve
192  * compatibility with old code which inadvertently called the API without
193  * checking for errors, or which called some methods outside of the expected
194  * order, librsvg will just emit a `g_critical()` message in those cases.
195  * 
196  * New methods introduced in librsvg 2.46 and later will check for the correct
197  * ordering, and panic if they are called out of order.  This will abort
198  * the program as if it had a failed assertion.
199  */
200 public class Handle : ObjectG
201 {
202 	/** the main Gtk struct */
203 	protected RsvgHandle* rsvgHandle;
204 
205 	/** Get the main Gtk struct */
206 	public RsvgHandle* getHandleStruct(bool transferOwnership = false)
207 	{
208 		if (transferOwnership)
209 			ownedRef = false;
210 		return rsvgHandle;
211 	}
212 
213 	/** the main Gtk struct as a void* */
214 	protected override void* getStruct()
215 	{
216 		return cast(void*)rsvgHandle;
217 	}
218 
219 	/**
220 	 * Sets our main struct and passes it to the parent class.
221 	 */
222 	public this (RsvgHandle* rsvgHandle, bool ownedRef = false)
223 	{
224 		this.rsvgHandle = rsvgHandle;
225 		super(cast(GObject*)rsvgHandle, ownedRef);
226 	}
227 
228 
229 	/** */
230 	public static GType getType()
231 	{
232 		return rsvg_handle_get_type();
233 	}
234 
235 	/**
236 	 * Returns a new rsvg handle.  Must be freed with [method@GObject.Object.unref].  This
237 	 * handle can be used to load an image.
238 	 *
239 	 * The preferred way of loading SVG data into the returned [class@Rsvg.Handle] is with
240 	 * [method@Rsvg.Handle.read_stream_sync].
241 	 *
242 	 * The deprecated way of loading SVG data is with [method@Rsvg.Handle.write] and
243 	 * [method@Rsvg.Handle.close]; note that these require buffering the entire file
244 	 * internally, and for this reason it is better to use the stream functions:
245 	 * [ctor@Rsvg.Handle.new_from_stream_sync], [method@Rsvg.Handle.read_stream_sync], or
246 	 * [ctor@Rsvg.Handle.new_from_gfile_sync].
247 	 *
248 	 * After loading the [class@Rsvg.Handle] with data, you can render it using Cairo or get
249 	 * a GdkPixbuf from it. When finished, free the handle with [method@GObject.Object.unref]. No
250 	 * more than one image can be loaded with one handle.
251 	 *
252 	 * Note that this function creates an [class@Rsvg.Handle] with no flags set.  If you
253 	 * require any of [flags@Rsvg.HandleFlags] to be set, use any of
254 	 * [ctor@Rsvg.Handle.new_with_flags], [ctor@Rsvg.Handle.new_from_stream_sync], or
255 	 * [ctor@Rsvg.Handle.new_from_gfile_sync].
256 	 *
257 	 * Returns: A new [class@Rsvg.Handle] with no flags set.
258 	 *
259 	 * Throws: ConstructionException GTK+ fails to create the object.
260 	 */
261 	public this()
262 	{
263 		auto __p = rsvg_handle_new();
264 
265 		if(__p is null)
266 		{
267 			throw new ConstructionException("null returned by new");
268 		}
269 
270 		this(cast(RsvgHandle*) __p, true);
271 	}
272 
273 	/**
274 	 * Loads the SVG specified by @data.  Note that this function creates an
275 	 * [class@Rsvg.Handle] without a base URL, and without any [flags@Rsvg.HandleFlags].  If you
276 	 * need these, use [ctor@Rsvg.Handle.new_from_stream_sync] instead by creating
277 	 * a [class@Gio.MemoryInputStream] from your data.
278 	 *
279 	 * Params:
280 	 *     data = The SVG data
281 	 *
282 	 * Returns: A [class@Rsvg.Handle] or `NULL` if an error occurs.
283 	 *
284 	 * Since: 2.14
285 	 *
286 	 * Throws: GException on failure.
287 	 * Throws: ConstructionException GTK+ fails to create the object.
288 	 */
289 	public this(ubyte[] data)
290 	{
291 		GError* err = null;
292 
293 		auto __p = rsvg_handle_new_from_data(data.ptr, cast(size_t)data.length, &err);
294 
295 		if (err !is null)
296 		{
297 			throw new GException( new ErrorG(err) );
298 		}
299 
300 		if(__p is null)
301 		{
302 			throw new ConstructionException("null returned by new_from_data");
303 		}
304 
305 		this(cast(RsvgHandle*) __p, true);
306 	}
307 
308 	/**
309 	 * Loads the SVG specified by @file_name.  Note that this function, like
310 	 * [ctor@Rsvg.Handle.new], does not specify any loading flags for the resulting
311 	 * handle.  If you require the use of [flags@Rsvg.HandleFlags], use
312 	 * [ctor@Rsvg.Handle.new_from_gfile_sync].
313 	 *
314 	 * Params:
315 	 *     filename = The file name to load, or a URI.
316 	 *
317 	 * Returns: A [class@Rsvg.Handle] or `NULL` if an error occurs.
318 	 *
319 	 * Since: 2.14
320 	 *
321 	 * Throws: GException on failure.
322 	 * Throws: ConstructionException GTK+ fails to create the object.
323 	 */
324 	public this(string filename)
325 	{
326 		GError* err = null;
327 
328 		auto __p = rsvg_handle_new_from_file(Str.toStringz(filename), &err);
329 
330 		if (err !is null)
331 		{
332 			throw new GException( new ErrorG(err) );
333 		}
334 
335 		if(__p is null)
336 		{
337 			throw new ConstructionException("null returned by new_from_file");
338 		}
339 
340 		this(cast(RsvgHandle*) __p, true);
341 	}
342 
343 	/**
344 	 * Creates a new [class@Rsvg.Handle] for @file.
345 	 *
346 	 * This function sets the "base file" of the handle to be @file itself, so SVG
347 	 * elements like `<image>` which reference external
348 	 * resources will be resolved relative to the location of @file.
349 	 *
350 	 * If @cancellable is not `NULL`, then the operation can be cancelled by
351 	 * triggering the cancellable object from another thread. If the
352 	 * operation was cancelled, the error `G_IO_ERROR_CANCELLED` will be
353 	 * returned in @error.
354 	 *
355 	 * Params:
356 	 *     file = a `GFile`
357 	 *     flags = flags from [flags@Rsvg.HandleFlags]
358 	 *     cancellable = a `GCancellable`, or `NULL`
359 	 *
360 	 * Returns: a new [class@Rsvg.Handle] on success, or `NULL` with @error filled in
361 	 *
362 	 * Since: 2.32
363 	 *
364 	 * Throws: GException on failure.
365 	 * Throws: ConstructionException GTK+ fails to create the object.
366 	 */
367 	public this(FileIF file, RsvgHandleFlags flags, Cancellable cancellable)
368 	{
369 		GError* err = null;
370 
371 		auto __p = rsvg_handle_new_from_gfile_sync((file is null) ? null : file.getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
372 
373 		if (err !is null)
374 		{
375 			throw new GException( new ErrorG(err) );
376 		}
377 
378 		if(__p is null)
379 		{
380 			throw new ConstructionException("null returned by new_from_gfile_sync");
381 		}
382 
383 		this(cast(RsvgHandle*) __p, true);
384 	}
385 
386 	/**
387 	 * Creates a new [class@Rsvg.Handle] for @stream.
388 	 *
389 	 * This function sets the "base file" of the handle to be @base_file if
390 	 * provided.  SVG elements like `<image>` which reference
391 	 * external resources will be resolved relative to the location of @base_file.
392 	 *
393 	 * If @cancellable is not `NULL`, then the operation can be cancelled by
394 	 * triggering the cancellable object from another thread. If the
395 	 * operation was cancelled, the error `G_IO_ERROR_CANCELLED` will be
396 	 * returned in @error.
397 	 *
398 	 * Params:
399 	 *     inputStream = a `GInputStream`
400 	 *     baseFile = a `GFile`, or `NULL`
401 	 *     flags = flags from [flags@Rsvg.HandleFlags]
402 	 *     cancellable = a `GCancellable`, or `NULL`
403 	 *
404 	 * Returns: a new [class@Rsvg.Handle] on success, or `NULL` with @error filled in
405 	 *
406 	 * Since: 2.32
407 	 *
408 	 * Throws: GException on failure.
409 	 * Throws: ConstructionException GTK+ fails to create the object.
410 	 */
411 	public this(InputStream inputStream, FileIF baseFile, RsvgHandleFlags flags, Cancellable cancellable)
412 	{
413 		GError* err = null;
414 
415 		auto __p = rsvg_handle_new_from_stream_sync((inputStream is null) ? null : inputStream.getInputStreamStruct(), (baseFile is null) ? null : baseFile.getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
416 
417 		if (err !is null)
418 		{
419 			throw new GException( new ErrorG(err) );
420 		}
421 
422 		if(__p is null)
423 		{
424 			throw new ConstructionException("null returned by new_from_stream_sync");
425 		}
426 
427 		this(cast(RsvgHandle*) __p, true);
428 	}
429 
430 	/**
431 	 * Creates a new [class@Rsvg.Handle] with flags @flags.  After calling this function,
432 	 * you can feed the resulting handle with SVG data by using
433 	 * [method@Rsvg.Handle.read_stream_sync].
434 	 *
435 	 * Params:
436 	 *     flags = flags from [flags@Rsvg.HandleFlags]
437 	 *
438 	 * Returns: a new [class@Rsvg.Handle]
439 	 *
440 	 * Since: 2.36
441 	 *
442 	 * Throws: ConstructionException GTK+ fails to create the object.
443 	 */
444 	public this(RsvgHandleFlags flags)
445 	{
446 		auto __p = rsvg_handle_new_with_flags(flags);
447 
448 		if(__p is null)
449 		{
450 			throw new ConstructionException("null returned by new_with_flags");
451 		}
452 
453 		this(cast(RsvgHandle*) __p, true);
454 	}
455 
456 	/**
457 	 * This is used after calling [method@Rsvg.Handle.write] to indicate that there is no more data
458 	 * to consume, and to start the actual parsing of the SVG document.  The only reason to
459 	 * call this function is if you use use [method@Rsvg.Handle.write] to feed data into the @handle;
460 	 * if you use the other methods like [ctor@Rsvg.Handle.new_from_file] or
461 	 * [method@Rsvg.Handle.read_stream_sync], then you do not need to call this function.
462 	 *
463 	 * This will return `TRUE` if the loader closed successfully and the
464 	 * SVG data was parsed correctly.  Note that @handle isn't freed until
465 	 * [method@GObject.Object.unref] is called.
466 	 *
467 	 * Deprecated: Use [method@Rsvg.Handle.read_stream_sync] or the constructor
468 	 * functions [ctor@Rsvg.Handle.new_from_gfile_sync] or
469 	 * [ctor@Rsvg.Handle.new_from_stream_sync].  See the deprecation notes for
470 	 * [method@Rsvg.Handle.write] for more information.
471 	 *
472 	 * Returns: `TRUE` on success, or `FALSE` on error.
473 	 *
474 	 * Throws: GException on failure.
475 	 */
476 	public bool close()
477 	{
478 		GError* err = null;
479 
480 		auto __p = rsvg_handle_close(rsvgHandle, &err) != 0;
481 
482 		if (err !is null)
483 		{
484 			throw new GException( new ErrorG(err) );
485 		}
486 
487 		return __p;
488 	}
489 
490 	/**
491 	 * Frees @handle.
492 	 *
493 	 * Deprecated: Use [method@GObject.Object.unref] instead.
494 	 */
495 	public void free()
496 	{
497 		rsvg_handle_free(rsvgHandle);
498 	}
499 
500 	/**
501 	 * Gets the base uri for this [class@Rsvg.Handle].
502 	 *
503 	 * Returns: the base uri, possibly null
504 	 *
505 	 * Since: 2.8
506 	 */
507 	public string getBaseUri()
508 	{
509 		return Str.toString(rsvg_handle_get_base_uri(rsvgHandle));
510 	}
511 
512 	/**
513 	 *
514 	 *
515 	 * Deprecated: Librsvg does not read the metadata/desc/title elements;
516 	 * this function always returns `NULL`.
517 	 *
518 	 * Returns: This function always returns `NULL`.
519 	 *
520 	 * Since: 2.4
521 	 */
522 	public string getDesc()
523 	{
524 		return Str.toString(rsvg_handle_get_desc(rsvgHandle));
525 	}
526 
527 	/**
528 	 * Get the SVG's size. Do not call from within the size_func callback, because
529 	 * an infinite loop will occur.
530 	 *
531 	 * This function depends on the [class@Rsvg.Handle]'s DPI to compute dimensions in
532 	 * pixels, so you should call [method@Rsvg.Handle.set_dpi] beforehand.
533 	 *
534 	 * Deprecated: Use [method@Rsvg.Handle.get_intrinsic_size_in_pixels] instead.  This
535 	 * function is deprecated because it is not able to return exact fractional dimensions,
536 	 * only integer pixels.
537 	 *
538 	 * Params:
539 	 *     dimensionData = A place to store the SVG's size
540 	 *
541 	 * Since: 2.14
542 	 */
543 	public void getDimensions(out RsvgDimensionData dimensionData)
544 	{
545 		rsvg_handle_get_dimensions(rsvgHandle, &dimensionData);
546 	}
547 
548 	/**
549 	 * Get the size of a subelement of the SVG file. Do not call from within the
550 	 * size_func callback, because an infinite loop will occur.
551 	 *
552 	 * This function depends on the [class@Rsvg.Handle]'s DPI to compute dimensions in
553 	 * pixels, so you should call [method@Rsvg.Handle.set_dpi] beforehand.
554 	 *
555 	 * Element IDs should look like an URL fragment identifier; for example, pass
556 	 * `#foo` (hash `foo`) to get the geometry of the element that
557 	 * has an `id="foo"` attribute.
558 	 *
559 	 * Deprecated: Use [method@Rsvg.Handle.get_geometry_for_layer] instead.
560 	 *
561 	 * Params:
562 	 *     dimensionData = A place to store the SVG's size
563 	 *     id = An element's id within the SVG, starting with "#" (a single
564 	 *         hash character), for example, `#layer1`.  This notation corresponds to a
565 	 *         URL's fragment ID.  Alternatively, pass `NULL` to use the whole SVG.
566 	 *
567 	 * Returns: `TRUE` if the dimensions could be obtained, `FALSE` if there was an error.
568 	 *
569 	 * Since: 2.22
570 	 */
571 	public bool getDimensionsSub(out RsvgDimensionData dimensionData, string id)
572 	{
573 		return rsvg_handle_get_dimensions_sub(rsvgHandle, &dimensionData, Str.toStringz(id)) != 0;
574 	}
575 
576 	/**
577 	 * Computes the ink rectangle and logical rectangle of a single SVG element.
578 	 *
579 	 * While `rsvg_handle_get_geometry_for_layer` computes the geometry of an SVG element subtree with
580 	 * its transformation matrix, this other function will compute the element's geometry
581 	 * as if it were being rendered under an identity transformation by itself.  That is,
582 	 * the resulting geometry is as if the element got extracted by itself from the SVG.
583 	 *
584 	 * This function is the counterpart to `rsvg_handle_render_element`.
585 	 *
586 	 * Element IDs should look like an URL fragment identifier; for example, pass
587 	 * `#foo` (hash `foo`) to get the geometry of the element that
588 	 * has an `id="foo"` attribute.
589 	 *
590 	 * The "ink rectangle" is the bounding box that would be painted
591 	 * for fully- stroked and filled elements.
592 	 *
593 	 * The "logical rectangle" just takes into account the unstroked
594 	 * paths and text outlines.
595 	 *
596 	 * Note that these bounds are not minimum bounds; for example,
597 	 * clipping paths are not taken into account.
598 	 *
599 	 * You can pass `NULL` for the @id if you want to measure all
600 	 * the elements in the SVG, i.e. to measure everything from the
601 	 * root element.
602 	 *
603 	 * This operation is not constant-time, as it involves going through all
604 	 * the child elements.
605 	 *
606 	 * Params:
607 	 *     id = An element's id within the SVG, starting with "#" (a single
608 	 *         hash character), for example, `#layer1`.  This notation corresponds to a
609 	 *         URL's fragment ID.  Alternatively, pass `NULL` to compute the geometry for the
610 	 *         whole SVG.
611 	 *     outInkRect = Place to store the ink rectangle of the element.
612 	 *     outLogicalRect = Place to store the logical rectangle of the element.
613 	 *
614 	 * Returns: `TRUE` if the geometry could be obtained, or `FALSE` on error.  Errors
615 	 *     are returned in the @error argument.
616 	 *
617 	 *     API ordering: This function must be called on a fully-loaded @handle.  See
618 	 *     the section "[API ordering](class.Handle.html#api-ordering)" for details.
619 	 *
620 	 *     Panics: this function will panic if the @handle is not fully-loaded.
621 	 *
622 	 * Since: 2.46
623 	 *
624 	 * Throws: GException on failure.
625 	 */
626 	public bool getGeometryForElement(string id, out RsvgRectangle outInkRect, out RsvgRectangle outLogicalRect)
627 	{
628 		GError* err = null;
629 
630 		auto __p = rsvg_handle_get_geometry_for_element(rsvgHandle, Str.toStringz(id), &outInkRect, &outLogicalRect, &err) != 0;
631 
632 		if (err !is null)
633 		{
634 			throw new GException( new ErrorG(err) );
635 		}
636 
637 		return __p;
638 	}
639 
640 	/**
641 	 * Computes the ink rectangle and logical rectangle of an SVG element, or the
642 	 * whole SVG, as if the whole SVG were rendered to a specific viewport.
643 	 *
644 	 * Element IDs should look like an URL fragment identifier; for example, pass
645 	 * `#foo` (hash `foo`) to get the geometry of the element that
646 	 * has an `id="foo"` attribute.
647 	 *
648 	 * The "ink rectangle" is the bounding box that would be painted
649 	 * for fully-stroked and filled elements.
650 	 *
651 	 * The "logical rectangle" just takes into account the unstroked
652 	 * paths and text outlines.
653 	 *
654 	 * Note that these bounds are not minimum bounds; for example,
655 	 * clipping paths are not taken into account.
656 	 *
657 	 * You can pass `NULL` for the @id if you want to measure all
658 	 * the elements in the SVG, i.e. to measure everything from the
659 	 * root element.
660 	 *
661 	 * This operation is not constant-time, as it involves going through all
662 	 * the child elements.
663 	 *
664 	 * Params:
665 	 *     id = An element's id within the SVG, starting with "#" (a single
666 	 *         hash character), for example, `#layer1`.  This notation corresponds to a
667 	 *         URL's fragment ID.  Alternatively, pass `NULL` to compute the geometry for the
668 	 *         whole SVG.
669 	 *     viewport = Viewport size at which the whole SVG would be fitted.
670 	 *     outInkRect = Place to store the ink rectangle of the element.
671 	 *     outLogicalRect = Place to store the logical rectangle of the element.
672 	 *
673 	 * Returns: `TRUE` if the geometry could be obtained, or `FALSE` on error.  Errors
674 	 *     are returned in the @error argument.
675 	 *
676 	 *     API ordering: This function must be called on a fully-loaded @handle.  See
677 	 *     the section "[API ordering](class.Handle.html#api-ordering)" for details.
678 	 *
679 	 *     Panics: this function will panic if the @handle is not fully-loaded.
680 	 *
681 	 * Since: 2.46
682 	 *
683 	 * Throws: GException on failure.
684 	 */
685 	public bool getGeometryForLayer(string id, RsvgRectangle* viewport, out RsvgRectangle outInkRect, out RsvgRectangle outLogicalRect)
686 	{
687 		GError* err = null;
688 
689 		auto __p = rsvg_handle_get_geometry_for_layer(rsvgHandle, Str.toStringz(id), viewport, &outInkRect, &outLogicalRect, &err) != 0;
690 
691 		if (err !is null)
692 		{
693 			throw new GException( new ErrorG(err) );
694 		}
695 
696 		return __p;
697 	}
698 
699 	/**
700 	 * In simple terms, queries the `width`, `height`, and `viewBox` attributes in an SVG document.
701 	 *
702 	 * If you are calling this function to compute a scaling factor to render the SVG,
703 	 * consider simply using [method@Rsvg.Handle.render_document] instead; it will do the
704 	 * scaling computations automatically.
705 	 *
706 	 * Before librsvg 2.54.0, the `out_has_width` and `out_has_height` arguments would be set to true or false
707 	 * depending on whether the SVG document actually had `width` and `height` attributes, respectively.
708 	 *
709 	 * However, since librsvg 2.54.0, `width` and `height` are now [geometry
710 	 * properties](https://www.w3.org/TR/SVG2/geometry.html) per the SVG2 specification; they
711 	 * are not plain attributes.  SVG2 made it so that the initial value of those properties
712 	 * is `auto`, which is equivalent to specifing a value of `100%`.  In this sense, even SVG
713 	 * documents which lack `width` or `height` attributes semantically have to make them
714 	 * default to `100%`.  This is why since librsvg 2.54.0, `out_has_width` and
715 	 * `out_has_heigth` are always returned as `TRUE`, since with SVG2 all documents *have* a
716 	 * default width and height of `100%`.
717 	 *
718 	 * As an example, the following SVG element has a `width` of 100 pixels and a `height` of 400 pixels, but no `viewBox`.  This
719 	 * function will return those sizes in `out_width` and `out_height`, and set `out_has_viewbox` to `FALSE`.
720 	 *
721 	 * ```
722 	 * <svg xmlns="http://www.w3.org/2000/svg" width="100" height="400">
723 	 * ```
724 	 *
725 	 * Conversely, the following element has a `viewBox`, but no `width` or `height`.  This function will
726 	 * set `out_has_viewbox` to `TRUE`, and it will also set `out_has_width` and `out_has_height` to `TRUE` but
727 	 * return both length values as `100%`.
728 	 *
729 	 * ```
730 	 * <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 400">
731 	 * ```
732 	 *
733 	 * Note that the `RsvgLength` return values have `RsvgUnits` in them; you should
734 	 * not assume that they are always in pixels.  For example, the following SVG element
735 	 * will return width and height values whose `units` fields are `RSVG_UNIT_MM`.
736 	 *
737 	 * ```
738 	 * <svg xmlns="http://www.w3.org/2000/svg" width="210mm" height="297mm">
739 	 * ```
740 	 *
741 	 * API ordering: This function must be called on a fully-loaded @handle.  See
742 	 * the section "[API ordering](class.Handle.html#api-ordering)" for details.
743 	 *
744 	 * Panics: this function will panic if the @handle is not fully-loaded.
745 	 *
746 	 * Params:
747 	 *     outHasWidth = Will be set to `TRUE`; see below.
748 	 *     outWidth = Will be set to the computed value of the `width` property in the toplevel SVG.
749 	 *     outHasHeight = Will be set to `TRUE`; see below.
750 	 *     outHeight = Will be set to the computed value of the `height` property in the toplevel SVG.
751 	 *     outHasViewbox = Will be set to `TRUE` if the toplevel SVG has a `viewBox` attribute
752 	 *     outViewbox = Will be set to the value of the `viewBox` attribute in the toplevel SVG
753 	 *
754 	 * Since: 2.46
755 	 */
756 	public void getIntrinsicDimensions(out bool outHasWidth, out RsvgLength outWidth, out bool outHasHeight, out RsvgLength outHeight, out bool outHasViewbox, out RsvgRectangle outViewbox)
757 	{
758 		int outoutHasWidth;
759 		int outoutHasHeight;
760 		int outoutHasViewbox;
761 
762 		rsvg_handle_get_intrinsic_dimensions(rsvgHandle, &outoutHasWidth, &outWidth, &outoutHasHeight, &outHeight, &outoutHasViewbox, &outViewbox);
763 
764 		outHasWidth = (outoutHasWidth == 1);
765 		outHasHeight = (outoutHasHeight == 1);
766 		outHasViewbox = (outoutHasViewbox == 1);
767 	}
768 
769 	/**
770 	 * Converts an SVG document's intrinsic dimensions to pixels, and returns the result.
771 	 *
772 	 * This function is able to extract the size in pixels from an SVG document if the
773 	 * document has both `width` and `height` attributes
774 	 * with physical units (px, in, cm, mm, pt, pc) or font-based units (em, ex).  For
775 	 * physical units, the dimensions are normalized to pixels using the dots-per-inch (DPI)
776 	 * value set previously with [method@Rsvg.Handle.set_dpi].  For font-based units, this function
777 	 * uses the computed value of the `font-size` property for the toplevel
778 	 * `<svg>` element.  In those cases, this function returns `TRUE`.
779 	 *
780 	 * This function is not able to extract the size in pixels directly from the intrinsic
781 	 * dimensions of the SVG document if the `width` or
782 	 * `height` are in percentage units (or if they do not exist, in which
783 	 * case the SVG spec mandates that they default to 100%), as these require a
784 	 * <firstterm>viewport</firstterm> to be resolved to a final size.  In this case, the
785 	 * function returns `FALSE`.
786 	 *
787 	 * For example, the following document fragment has intrinsic dimensions that will resolve
788 	 * to 20x30 pixels.
789 	 *
790 	 * ```
791 	 * <svg xmlns="http://www.w3.org/2000/svg" width="20" height="30"/>
792 	 * ```
793 	 *
794 	 * Similarly, if the DPI is set to 96, this document will resolve to 192×288 pixels (i.e. 96×2 × 96×3).
795 	 *
796 	 * ```
797 	 * <svg xmlns="http://www.w3.org/2000/svg" width="2in" height="3in"/>
798 	 * ```
799 	 *
800 	 * The dimensions of the following documents cannot be resolved to pixels directly, and
801 	 * this function would return `FALSE` for them:
802 	 *
803 	 * ```
804 	 * <!-- Needs a viewport against which to compute the percentages. -->
805 	 * <svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%"/>
806 	 *
807 	 * <!-- Does not have intrinsic width/height, just a 1:2 aspect ratio which
808 	 * needs to be fitted within a viewport. -->
809 	 * <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 200"/>
810 	 * ```
811 	 *
812 	 * Instead of querying an SVG document's size, applications are encouraged to render SVG
813 	 * documents to a size chosen by the application, by passing a suitably-sized viewport to
814 	 * [method@Rsvg.Handle.render_document].
815 	 *
816 	 * Params:
817 	 *     outWidth = Will be set to the computed width; you should round this up to get integer pixels.
818 	 *     outHeight = Will be set to the computed height; you should round this up to get integer pixels.
819 	 *
820 	 * Returns: `TRUE` if the dimensions could be converted directly to pixels; in this case
821 	 *     @out_width and @out_height will be set accordingly.  Note that the dimensions are
822 	 *     floating-point numbers, so your application can know the exact size of an SVG document.
823 	 *     To get integer dimensions, you should use `ceil()` to round up to the nearest integer
824 	 *     (just using `round()`, may may chop off pixels with fractional coverage).  If the
825 	 *     dimensions cannot be converted to pixels, returns `FALSE` and puts 0.0 in both
826 	 *     @out_width and @out_height.
827 	 *
828 	 * Since: 2.52
829 	 */
830 	public bool getIntrinsicSizeInPixels(out double outWidth, out double outHeight)
831 	{
832 		return rsvg_handle_get_intrinsic_size_in_pixels(rsvgHandle, &outWidth, &outHeight) != 0;
833 	}
834 
835 	/**
836 	 *
837 	 *
838 	 * Deprecated: Librsvg does not read the metadata/desc/title elements;
839 	 * this function always returns `NULL`.
840 	 *
841 	 * Returns: This function always returns `NULL`.
842 	 *
843 	 * Since: 2.9
844 	 */
845 	public string getMetadata()
846 	{
847 		return Str.toString(rsvg_handle_get_metadata(rsvgHandle));
848 	}
849 
850 	/**
851 	 * Returns the pixbuf loaded by @handle.  The pixbuf returned will be reffed, so
852 	 * the caller of this function must assume that ref.
853 	 *
854 	 * API ordering: This function must be called on a fully-loaded @handle.  See
855 	 * the section "[API ordering](class.Handle.html#api-ordering)" for details.
856 	 *
857 	 * This function depends on the [class@Rsvg.Handle]'s dots-per-inch value (DPI) to compute the
858 	 * "natural size" of the document in pixels, so you should call [method@Rsvg.Handle.set_dpi]
859 	 * beforehand.
860 	 *
861 	 * Returns: A pixbuf, or %NULL on error.
862 	 *     during rendering.
863 	 */
864 	public Pixbuf getPixbuf()
865 	{
866 		auto __p = rsvg_handle_get_pixbuf(rsvgHandle);
867 
868 		if(__p is null)
869 		{
870 			return null;
871 		}
872 
873 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) __p, true);
874 	}
875 
876 	/**
877 	 * Creates a `GdkPixbuf` the same size as the entire SVG loaded into @handle, but
878 	 * only renders the sub-element that has the specified @id (and all its
879 	 * sub-sub-elements recursively).  If @id is `NULL`, this function renders the
880 	 * whole SVG.
881 	 *
882 	 * This function depends on the [class@Rsvg.Handle]'s dots-per-inch value (DPI) to compute the
883 	 * "natural size" of the document in pixels, so you should call [method@Rsvg.Handle.set_dpi]
884 	 * beforehand.
885 	 *
886 	 * If you need to render an image which is only big enough to fit a particular
887 	 * sub-element of the SVG, consider using [method@Rsvg.Handle.render_element].
888 	 *
889 	 * Element IDs should look like an URL fragment identifier; for example, pass
890 	 * `#foo` (hash `foo`) to get the geometry of the element that
891 	 * has an `id="foo"` attribute.
892 	 *
893 	 * API ordering: This function must be called on a fully-loaded @handle.  See
894 	 * the section "[API ordering](class.Handle.html#api-ordering)" for details.
895 	 *
896 	 * Params:
897 	 *     id = An element's id within the SVG, starting with "#" (a single
898 	 *         hash character), for example, `#layer1`.  This notation corresponds to a
899 	 *         URL's fragment ID.  Alternatively, pass `NULL` to use the whole SVG.
900 	 *
901 	 * Returns: a pixbuf, or `NULL` if an error occurs
902 	 *     during rendering.
903 	 *
904 	 * Since: 2.14
905 	 */
906 	public Pixbuf getPixbufSub(string id)
907 	{
908 		auto __p = rsvg_handle_get_pixbuf_sub(rsvgHandle, Str.toStringz(id));
909 
910 		if(__p is null)
911 		{
912 			return null;
913 		}
914 
915 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) __p, true);
916 	}
917 
918 	/**
919 	 * Get the position of a subelement of the SVG file. Do not call from within
920 	 * the size_func callback, because an infinite loop will occur.
921 	 *
922 	 * This function depends on the [class@Rsvg.Handle]'s DPI to compute dimensions in
923 	 * pixels, so you should call [method@Rsvg.Handle.set_dpi] beforehand.
924 	 *
925 	 * Element IDs should look like an URL fragment identifier; for example, pass
926 	 * `#foo` (hash `foo`) to get the geometry of the element that
927 	 * has an `id="foo"` attribute.
928 	 *
929 	 * Deprecated: Use [method@Rsvg.Handle.get_geometry_for_layer] instead.  This function is
930 	 * deprecated since it is not able to return exact floating-point positions, only integer
931 	 * pixels.
932 	 *
933 	 * Params:
934 	 *     positionData = A place to store the SVG fragment's position.
935 	 *     id = An element's id within the SVG, starting with "#" (a single
936 	 *         hash character), for example, `#layer1`.  This notation corresponds to a
937 	 *         URL's fragment ID.  Alternatively, pass %NULL to use the whole SVG.
938 	 *
939 	 * Returns: `TRUE` if the position could be obtained, `FALSE` if there was an error.
940 	 *
941 	 * Since: 2.22
942 	 */
943 	public bool getPositionSub(out RsvgPositionData positionData, string id)
944 	{
945 		return rsvg_handle_get_position_sub(rsvgHandle, &positionData, Str.toStringz(id)) != 0;
946 	}
947 
948 	/**
949 	 *
950 	 *
951 	 * Deprecated: Librsvg does not read the metadata/desc/title elements;
952 	 * this function always returns `NULL`.
953 	 *
954 	 * Returns: This function always returns `NULL`.
955 	 *
956 	 * Since: 2.4
957 	 */
958 	public string getTitle()
959 	{
960 		return Str.toString(rsvg_handle_get_title(rsvgHandle));
961 	}
962 
963 	/**
964 	 * Checks whether the element @id exists in the SVG document.
965 	 *
966 	 * Element IDs should look like an URL fragment identifier; for example, pass
967 	 * `#foo` (hash `foo`) to get the geometry of the element that
968 	 * has an `id="foo"` attribute.
969 	 *
970 	 * Params:
971 	 *     id = An element's id within the SVG, starting with "#" (a single hash
972 	 *         character), for example, `#layer1`.  This notation corresponds to a URL's
973 	 *         fragment ID.
974 	 *
975 	 * Returns: `TRUE` if @id exists in the SVG document, `FALSE` otherwise.
976 	 *
977 	 * Since: 2.22
978 	 */
979 	public bool hasSub(string id)
980 	{
981 		return rsvg_handle_has_sub(rsvgHandle, Str.toStringz(id)) != 0;
982 	}
983 
984 	/**
985 	 * Do not call this function.  This is intended for librsvg's internal
986 	 * test suite only.
987 	 *
988 	 * Params:
989 	 *     testing = Whether to enable testing mode
990 	 */
991 	public void internalSetTesting(bool testing)
992 	{
993 		rsvg_handle_internal_set_testing(rsvgHandle, testing);
994 	}
995 
996 	/**
997 	 * Reads @stream and writes the data from it to @handle.
998 	 *
999 	 * Before calling this function, you may need to call [method@Rsvg.Handle.set_base_uri]
1000 	 * or [method@Rsvg.Handle.set_base_gfile] to set the "base file" for resolving
1001 	 * references to external resources.  SVG elements like
1002 	 * `<image>` which reference external resources will be
1003 	 * resolved relative to the location you specify with those functions.
1004 	 *
1005 	 * If @cancellable is not `NULL`, then the operation can be cancelled by
1006 	 * triggering the cancellable object from another thread. If the
1007 	 * operation was cancelled, the error `G_IO_ERROR_CANCELLED` will be
1008 	 * returned.
1009 	 *
1010 	 * Params:
1011 	 *     stream = a `GInputStream`
1012 	 *     cancellable = a `GCancellable`, or `NULL`
1013 	 *
1014 	 * Returns: `TRUE` if reading @stream succeeded, or `FALSE` otherwise
1015 	 *     with @error filled in
1016 	 *
1017 	 * Since: 2.32
1018 	 *
1019 	 * Throws: GException on failure.
1020 	 */
1021 	public bool readStreamSync(InputStream stream, Cancellable cancellable)
1022 	{
1023 		GError* err = null;
1024 
1025 		auto __p = rsvg_handle_read_stream_sync(rsvgHandle, (stream is null) ? null : stream.getInputStreamStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
1026 
1027 		if (err !is null)
1028 		{
1029 			throw new GException( new ErrorG(err) );
1030 		}
1031 
1032 		return __p;
1033 	}
1034 
1035 	/**
1036 	 * Draws a loaded SVG handle to a Cairo context.  Please try to use
1037 	 * [method@Rsvg.Handle.render_document] instead, which allows you to pick the size
1038 	 * at which the document will be rendered.
1039 	 *
1040 	 * Historically this function has picked a size by itself, based on the following rules:
1041 	 *
1042 	 * * If the SVG document has both `width` and `height`
1043 	 * attributes with physical units (px, in, cm, mm, pt, pc) or font-based units (em,
1044 	 * ex), the function computes the size directly based on the dots-per-inch (DPI) you
1045 	 * have configured with [method@Rsvg.Handle.set_dpi].  This is the same approach as
1046 	 * [method@Rsvg.Handle.get_intrinsic_size_in_pixels].
1047 	 *
1048 	 * * Otherwise, if there is a `viewBox` attribute and both
1049 	 * `width` and `height` are set to
1050 	 * `100%` (or if they don't exist at all and thus default to 100%),
1051 	 * the function uses the width and height of the `viewBox` as a pixel size.  This
1052 	 * produces a rendered document with the correct aspect ratio.
1053 	 *
1054 	 * * Otherwise, this function computes the extents of every graphical object in the SVG
1055 	 * document to find the total extents.  This is moderately expensive, but no more expensive
1056 	 * than rendering the whole document, for example.
1057 	 *
1058 	 * * This function cannot deal with percentage-based units for `width`
1059 	 * and `height` because there is no viewport against which they could
1060 	 * be resolved; that is why it will compute the extents of objects in that case.  This
1061 	 * is why we recommend that you use [method@Rsvg.Handle.render_document] instead, which takes
1062 	 * in a viewport and follows the sizing policy from the web platform.
1063 	 *
1064 	 * Drawing will occur with respect to the @cr's current transformation: for example, if
1065 	 * the @cr has a rotated current transformation matrix, the whole SVG will be rotated in
1066 	 * the rendered version.
1067 	 *
1068 	 * This function depends on the [class@Rsvg.Handle]'s DPI to compute dimensions in
1069 	 * pixels, so you should call [method@Rsvg.Handle.set_dpi] beforehand.
1070 	 *
1071 	 * Note that @cr must be a Cairo context that is not in an error state, that is,
1072 	 * `cairo_status()` must return `CAIRO_STATUS_SUCCESS` for it.  Cairo can set a
1073 	 * context to be in an error state in various situations, for example, if it was
1074 	 * passed an invalid matrix or if it was created for an invalid surface.
1075 	 *
1076 	 * Deprecated: Please use [method@Rsvg.Handle.render_document] instead; that function lets
1077 	 * you pass a viewport and obtain a good error message.
1078 	 *
1079 	 * Params:
1080 	 *     cr = A Cairo context
1081 	 *
1082 	 * Returns: `TRUE` if drawing succeeded; `FALSE` otherwise.
1083 	 *
1084 	 * Since: 2.14
1085 	 */
1086 	public bool renderCairo(Context cr)
1087 	{
1088 		return rsvg_handle_render_cairo(rsvgHandle, (cr is null) ? null : cr.getContextStruct()) != 0;
1089 	}
1090 
1091 	/**
1092 	 * Renders a single SVG element in the same place as for a whole SVG document (a "subset"
1093 	 * of the document).  Please try to use [method@Rsvg.Handle.render_layer] instead, which allows
1094 	 * you to pick the size at which the document with the layer will be rendered.
1095 	 *
1096 	 * This is equivalent to [method@Rsvg.Handle.render_cairo], but it renders only a single
1097 	 * element and its children, as if they composed an individual layer in the SVG.
1098 	 *
1099 	 * Historically this function has picked a size for the whole document by itself, based
1100 	 * on the following rules:
1101 	 *
1102 	 * * If the SVG document has both `width` and `height`
1103 	 * attributes with physical units (px, in, cm, mm, pt, pc) or font-based units (em,
1104 	 * ex), the function computes the size directly based on the dots-per-inch (DPI) you
1105 	 * have configured with [method@Rsvg.Handle.set_dpi].  This is the same approach as
1106 	 * [method@Rsvg.Handle.get_intrinsic_size_in_pixels].
1107 	 *
1108 	 * * Otherwise, if there is a `viewBox` attribute and both
1109 	 * `width` and `height` are set to
1110 	 * `100%` (or if they don't exist at all and thus default to 100%),
1111 	 * the function uses the width and height of the `viewBox` as a pixel size.  This
1112 	 * produces a rendered document with the correct aspect ratio.
1113 	 *
1114 	 * * Otherwise, this function computes the extents of every graphical object in the SVG
1115 	 * document to find the total extents.  This is moderately expensive, but no more expensive
1116 	 * than rendering the whole document, for example.
1117 	 *
1118 	 * * This function cannot deal with percentage-based units for `width`
1119 	 * and `height` because there is no viewport against which they could
1120 	 * be resolved; that is why it will compute the extents of objects in that case.  This
1121 	 * is why we recommend that you use [method@Rsvg.Handle.render_layer] instead, which takes
1122 	 * in a viewport and follows the sizing policy from the web platform.
1123 	 *
1124 	 * Drawing will occur with respect to the @cr's current transformation: for example, if
1125 	 * the @cr has a rotated current transformation matrix, the whole SVG will be rotated in
1126 	 * the rendered version.
1127 	 *
1128 	 * This function depends on the [class@Rsvg.Handle]'s DPI to compute dimensions in
1129 	 * pixels, so you should call [method@Rsvg.Handle.set_dpi] beforehand.
1130 	 *
1131 	 * Note that @cr must be a Cairo context that is not in an error state, that is,
1132 	 * `cairo_status()` must return `CAIRO_STATUS_SUCCESS` for it.  Cairo can set a
1133 	 * context to be in an error state in various situations, for example, if it was
1134 	 * passed an invalid matrix or if it was created for an invalid surface.
1135 	 *
1136 	 * Element IDs should look like an URL fragment identifier; for example, pass
1137 	 * `#foo` (hash `foo`) to get the geometry of the element that
1138 	 * has an `id="foo"` attribute.
1139 	 *
1140 	 * Deprecated: Please use [method@Rsvg.Handle.render_layer] instead; that function lets
1141 	 * you pass a viewport and obtain a good error message.
1142 	 *
1143 	 * Params:
1144 	 *     cr = A Cairo context
1145 	 *     id = An element's id within the SVG, starting with "#" (a single
1146 	 *         hash character), for example, `#layer1`.  This notation corresponds to a
1147 	 *         URL's fragment ID.  Alternatively, pass `NULL` to render the whole SVG.
1148 	 *
1149 	 * Returns: `TRUE` if drawing succeeded; `FALSE` otherwise.
1150 	 *
1151 	 * Since: 2.14
1152 	 */
1153 	public bool renderCairoSub(Context cr, string id)
1154 	{
1155 		return rsvg_handle_render_cairo_sub(rsvgHandle, (cr is null) ? null : cr.getContextStruct(), Str.toStringz(id)) != 0;
1156 	}
1157 
1158 	/**
1159 	 * Renders the whole SVG document fitted to a viewport.
1160 	 *
1161 	 * The @viewport gives the position and size at which the whole SVG document will be
1162 	 * rendered.  The document is scaled proportionally to fit into this viewport.
1163 	 *
1164 	 * The @cr must be in a `CAIRO_STATUS_SUCCESS` state, or this function will not
1165 	 * render anything, and instead will return an error.
1166 	 *
1167 	 * Params:
1168 	 *     cr = A Cairo context
1169 	 *     viewport = Viewport size at which the whole SVG would be fitted.
1170 	 *
1171 	 * Returns: `TRUE` on success, `FALSE` on error.  Errors are returned
1172 	 *     in the @error argument.
1173 	 *
1174 	 *     API ordering: This function must be called on a fully-loaded @handle.  See
1175 	 *     the section "[API ordering](class.Handle.html#api-ordering)" for details.
1176 	 *
1177 	 *     Panics: this function will panic if the @handle is not fully-loaded.
1178 	 *
1179 	 * Since: 2.46
1180 	 *
1181 	 * Throws: GException on failure.
1182 	 */
1183 	public bool renderDocument(Context cr, RsvgRectangle* viewport)
1184 	{
1185 		GError* err = null;
1186 
1187 		auto __p = rsvg_handle_render_document(rsvgHandle, (cr is null) ? null : cr.getContextStruct(), viewport, &err) != 0;
1188 
1189 		if (err !is null)
1190 		{
1191 			throw new GException( new ErrorG(err) );
1192 		}
1193 
1194 		return __p;
1195 	}
1196 
1197 	/**
1198 	 * Renders a single SVG element to a given viewport.
1199 	 *
1200 	 * This function can be used to extract individual element subtrees and render them,
1201 	 * scaled to a given @element_viewport.  This is useful for applications which have
1202 	 * reusable objects in an SVG and want to render them individually; for example, an
1203 	 * SVG full of icons that are meant to be be rendered independently of each other.
1204 	 *
1205 	 * Element IDs should look like an URL fragment identifier; for example, pass
1206 	 * `#foo` (hash `foo`) to get the geometry of the element that
1207 	 * has an `id="foo"` attribute.
1208 	 *
1209 	 * You can pass `NULL` for the @id if you want to render all
1210 	 * the elements in the SVG, i.e. to render everything from the
1211 	 * root element.
1212 	 *
1213 	 * The `element_viewport` gives the position and size at which the named element will
1214 	 * be rendered.  FIXME: mention proportional scaling.
1215 	 *
1216 	 * Params:
1217 	 *     cr = A Cairo context
1218 	 *     id = An element's id within the SVG, starting with "#" (a single
1219 	 *         hash character), for example, `#layer1`.  This notation corresponds to a
1220 	 *         URL's fragment ID.  Alternatively, pass `NULL` to render the whole SVG document tree.
1221 	 *     elementViewport = Viewport size in which to fit the element
1222 	 *
1223 	 * Returns: `TRUE` on success, `FALSE` on error.  Errors are returned
1224 	 *     in the @error argument.
1225 	 *
1226 	 *     API ordering: This function must be called on a fully-loaded @handle.  See
1227 	 *     the section "[API ordering](class.Handle.html#api-ordering)" for details.
1228 	 *
1229 	 *     Panics: this function will panic if the @handle is not fully-loaded.
1230 	 *
1231 	 * Since: 2.46
1232 	 *
1233 	 * Throws: GException on failure.
1234 	 */
1235 	public bool renderElement(Context cr, string id, RsvgRectangle* elementViewport)
1236 	{
1237 		GError* err = null;
1238 
1239 		auto __p = rsvg_handle_render_element(rsvgHandle, (cr is null) ? null : cr.getContextStruct(), Str.toStringz(id), elementViewport, &err) != 0;
1240 
1241 		if (err !is null)
1242 		{
1243 			throw new GException( new ErrorG(err) );
1244 		}
1245 
1246 		return __p;
1247 	}
1248 
1249 	/**
1250 	 * Renders a single SVG element in the same place as for a whole SVG document.
1251 	 *
1252 	 * The @viewport gives the position and size at which the whole SVG document would be
1253 	 * rendered.  The document is scaled proportionally to fit into this viewport; hence the
1254 	 * individual layer may be smaller than this.
1255 	 *
1256 	 * This is equivalent to [method@Rsvg.Handle.render_document], but it renders only a
1257 	 * single element and its children, as if they composed an individual layer in
1258 	 * the SVG.  The element is rendered with the same transformation matrix as it
1259 	 * has within the whole SVG document.  Applications can use this to re-render a
1260 	 * single element and repaint it on top of a previously-rendered document, for
1261 	 * example.
1262 	 *
1263 	 * Element IDs should look like an URL fragment identifier; for example, pass
1264 	 * `#foo` (hash `foo`) to get the geometry of the element that
1265 	 * has an `id="foo"` attribute.
1266 	 *
1267 	 * You can pass `NULL` for the @id if you want to render all
1268 	 * the elements in the SVG, i.e. to render everything from the
1269 	 * root element.
1270 	 *
1271 	 * Params:
1272 	 *     cr = A Cairo context
1273 	 *     id = An element's id within the SVG, starting with "#" (a single
1274 	 *         hash character), for example, `#layer1`.  This notation corresponds to a
1275 	 *         URL's fragment ID.  Alternatively, pass `NULL` to render the whole SVG document tree.
1276 	 *     viewport = Viewport size at which the whole SVG would be fitted.
1277 	 *
1278 	 * Returns: `TRUE` on success, `FALSE` on error.  Errors are returned
1279 	 *     in the @error argument.
1280 	 *
1281 	 *     API ordering: This function must be called on a fully-loaded @handle.  See
1282 	 *     the section "[API ordering](class.Handle.html#api-ordering)" for details.
1283 	 *
1284 	 *     Panics: this function will panic if the @handle is not fully-loaded.
1285 	 *
1286 	 * Since: 2.46
1287 	 *
1288 	 * Throws: GException on failure.
1289 	 */
1290 	public bool renderLayer(Context cr, string id, RsvgRectangle* viewport)
1291 	{
1292 		GError* err = null;
1293 
1294 		auto __p = rsvg_handle_render_layer(rsvgHandle, (cr is null) ? null : cr.getContextStruct(), Str.toStringz(id), viewport, &err) != 0;
1295 
1296 		if (err !is null)
1297 		{
1298 			throw new GException( new ErrorG(err) );
1299 		}
1300 
1301 		return __p;
1302 	}
1303 
1304 	/**
1305 	 * Set the base URI for @handle from @file.
1306 	 *
1307 	 * Note: This function may only be called before [method@Rsvg.Handle.write] or
1308 	 * [method@Rsvg.Handle.read_stream_sync] have been called.
1309 	 *
1310 	 * Params:
1311 	 *     baseFile = a `GFile`
1312 	 *
1313 	 * Since: 2.32
1314 	 */
1315 	public void setBaseGfile(FileIF baseFile)
1316 	{
1317 		rsvg_handle_set_base_gfile(rsvgHandle, (baseFile is null) ? null : baseFile.getFileStruct());
1318 	}
1319 
1320 	/**
1321 	 * Set the base URI for this SVG.
1322 	 *
1323 	 * Note: This function may only be called before [method@Rsvg.Handle.write] or
1324 	 * [method@Rsvg.Handle.read_stream_sync] have been called.
1325 	 *
1326 	 * Params:
1327 	 *     baseUri = The base uri
1328 	 *
1329 	 * Since: 2.9
1330 	 */
1331 	public void setBaseUri(string baseUri)
1332 	{
1333 		rsvg_handle_set_base_uri(rsvgHandle, Str.toStringz(baseUri));
1334 	}
1335 
1336 	/**
1337 	 * Sets the DPI at which the @handle will be rendered. Common values are
1338 	 * 75, 90, and 300 DPI.
1339 	 *
1340 	 * Passing a number <= 0 to @dpi will reset the DPI to whatever the default
1341 	 * value happens to be, but since [id@rsvg_set_default_dpi] is deprecated, please
1342 	 * do not pass values <= 0 to this function.
1343 	 *
1344 	 * Params:
1345 	 *     dpi = Dots Per Inch (i.e. as Pixels Per Inch)
1346 	 *
1347 	 * Since: 2.8
1348 	 */
1349 	public void setDpi(double dpi)
1350 	{
1351 		rsvg_handle_set_dpi(rsvgHandle, dpi);
1352 	}
1353 
1354 	/**
1355 	 * Sets the DPI at which the @handle will be rendered. Common values are
1356 	 * 75, 90, and 300 DPI.
1357 	 *
1358 	 * Passing a number <= 0 to @dpi will reset the DPI to whatever the default
1359 	 * value happens to be, but since [id@rsvg_set_default_dpi_x_y] is deprecated,
1360 	 * please do not pass values <= 0 to this function.
1361 	 *
1362 	 * Params:
1363 	 *     dpiX = Dots Per Inch (i.e. Pixels Per Inch)
1364 	 *     dpiY = Dots Per Inch (i.e. Pixels Per Inch)
1365 	 *
1366 	 * Since: 2.8
1367 	 */
1368 	public void setDpiXY(double dpiX, double dpiY)
1369 	{
1370 		rsvg_handle_set_dpi_x_y(rsvgHandle, dpiX, dpiY);
1371 	}
1372 
1373 	/**
1374 	 * Sets the sizing function for the @handle, which can be used to override the
1375 	 * size that librsvg computes for SVG images.  The @size_func is called from the
1376 	 * following functions:
1377 	 *
1378 	 * * [method@Rsvg.Handle.get_dimensions]
1379 	 * * [method@Rsvg.Handle.get_dimensions_sub]
1380 	 * * [method@Rsvg.Handle.get_position_sub]
1381 	 * * [method@Rsvg.Handle.render_cairo]
1382 	 * * [method@Rsvg.Handle.render_cairo_sub]
1383 	 *
1384 	 * Librsvg computes the size of the SVG being rendered, and passes it to the
1385 	 * @size_func, which may then modify these values to set the final size of the
1386 	 * generated image.
1387 	 *
1388 	 * Deprecated: Use [method@Rsvg.Handle.render_document] instead.
1389 	 * This function was deprecated because when the @size_func is used, it makes it
1390 	 * unclear when the librsvg functions which call the @size_func will use the
1391 	 * size computed originally, or the callback-specified size, or whether it
1392 	 * refers to the whole SVG or to just a sub-element of it.  It is easier, and
1393 	 * unambiguous, to use code similar to the example above.
1394 	 *
1395 	 * Params:
1396 	 *     sizeFunc = A sizing function, or `NULL`
1397 	 *     userData = User data to pass to @size_func, or `NULL`
1398 	 *     userDataDestroy = Function to be called to destroy the data passed in @user_data,
1399 	 *         or `NULL`.
1400 	 */
1401 	public void setSizeCallback(RsvgSizeFunc sizeFunc, void* userData, GDestroyNotify userDataDestroy)
1402 	{
1403 		rsvg_handle_set_size_callback(rsvgHandle, sizeFunc, userData, userDataDestroy);
1404 	}
1405 
1406 	/**
1407 	 * Sets a CSS stylesheet to use for an SVG document.
1408 	 *
1409 	 * The @css_len argument is mandatory; this function will not compute the length
1410 	 * of the @css string.  This is because a provided stylesheet, which the calling
1411 	 * program could read from a file, can have nul characters in it.
1412 	 *
1413 	 * During the CSS cascade, the specified stylesheet will be used with a "User"
1414 	 * [origin](https://drafts.csswg.org/css-cascade-3/#cascading-origins).
1415 	 *
1416 	 * Note that `@import` rules will not be resolved, except for `data:` URLs.
1417 	 *
1418 	 * Params:
1419 	 *     css = String with CSS data; must be valid UTF-8.
1420 	 *
1421 	 * Returns: `TRUE` on success, `FALSE` on error.  Errors are returned
1422 	 *     in the @error argument.
1423 	 *
1424 	 * Since: 2.48
1425 	 *
1426 	 * Throws: GException on failure.
1427 	 */
1428 	public bool setStylesheet(ubyte[] css)
1429 	{
1430 		GError* err = null;
1431 
1432 		auto __p = rsvg_handle_set_stylesheet(rsvgHandle, css.ptr, cast(size_t)css.length, &err) != 0;
1433 
1434 		if (err !is null)
1435 		{
1436 			throw new GException( new ErrorG(err) );
1437 		}
1438 
1439 		return __p;
1440 	}
1441 
1442 	/**
1443 	 * Loads the next @count bytes of the image.  You can call this function multiple
1444 	 * times until the whole document is consumed; then you must call [method@Rsvg.Handle.close]
1445 	 * to actually parse the document.
1446 	 *
1447 	 * Before calling this function for the first time, you may need to call
1448 	 * [method@Rsvg.Handle.set_base_uri] or [method@Rsvg.Handle.set_base_gfile] to set the "base
1449 	 * file" for resolving references to external resources.  SVG elements like
1450 	 * `<image>` which reference external resources will be
1451 	 * resolved relative to the location you specify with those functions.
1452 	 *
1453 	 * Deprecated: Use [method@Rsvg.Handle.read_stream_sync] or the constructor
1454 	 * functions [ctor@Rsvg.Handle.new_from_gfile_sync] or
1455 	 * [ctor@Rsvg.Handle.new_from_stream_sync].  This function is deprecated because it
1456 	 * will accumulate data from the @buf in memory until [method@Rsvg.Handle.close] gets
1457 	 * called.  To avoid a big temporary buffer, use the suggested functions, which
1458 	 * take a `GFile` or a `GInputStream` and do not require a temporary buffer.
1459 	 *
1460 	 * Params:
1461 	 *     buf = pointer to svg data
1462 	 *
1463 	 * Returns: `TRUE` on success, or `FALSE` on error.
1464 	 *
1465 	 * Throws: GException on failure.
1466 	 */
1467 	public bool write(char[] buf)
1468 	{
1469 		GError* err = null;
1470 
1471 		auto __p = rsvg_handle_write(rsvgHandle, buf.ptr, cast(size_t)buf.length, &err) != 0;
1472 
1473 		if (err !is null)
1474 		{
1475 			throw new GException( new ErrorG(err) );
1476 		}
1477 
1478 		return __p;
1479 	}
1480 
1481 	/**
1482 	 * This function does nothing.
1483 	 *
1484 	 * Deprecated: No-op. This function should not be called from normal programs.
1485 	 *
1486 	 * Since: 2.36
1487 	 */
1488 	public static void cleanup()
1489 	{
1490 		rsvg_cleanup();
1491 	}
1492 
1493 	/**
1494 	 * Do not use this function.  Create an [class@Rsvg.Handle] and call
1495 	 * [method@Rsvg.Handle.set_dpi] on it instead.
1496 	 *
1497 	 * Deprecated: This function used to set a global default DPI.  However,
1498 	 * it only worked if it was called before any [class@Rsvg.Handle] objects had been
1499 	 * created; it would not work after that.  To avoid global mutable state, please
1500 	 * use [method@Rsvg.Handle.set_dpi] instead.
1501 	 *
1502 	 * Params:
1503 	 *     dpi = Dots Per Inch (aka Pixels Per Inch)
1504 	 *
1505 	 * Since: 2.8
1506 	 */
1507 	public static void setDefaultDpi(double dpi)
1508 	{
1509 		rsvg_set_default_dpi(dpi);
1510 	}
1511 
1512 	/**
1513 	 * Do not use this function.  Create an [class@Rsvg.Handle] and call
1514 	 * [method@Rsvg.Handle.set_dpi_x_y] on it instead.
1515 	 *
1516 	 * Deprecated: This function used to set a global default DPI.  However,
1517 	 * it only worked if it was called before any [class@Rsvg.Handle] objects had been
1518 	 * created; it would not work after that.  To avoid global mutable state, please
1519 	 * use [method@Rsvg.Handle.set_dpi] instead.
1520 	 *
1521 	 * Params:
1522 	 *     dpiX = Dots Per Inch (aka Pixels Per Inch)
1523 	 *     dpiY = Dots Per Inch (aka Pixels Per Inch)
1524 	 *
1525 	 * Since: 2.8
1526 	 */
1527 	public static void setDefaultDpiXY(double dpiX, double dpiY)
1528 	{
1529 		rsvg_set_default_dpi_x_y(dpiX, dpiY);
1530 	}
1531 }